<?php

require_once APPPATH . 'core/BaseDAO.php';

use models\M_servicio_adicional;

class ServicioAdicionalDAO extends BaseDAO {

    function __construct() {
        parent::__construct();
    }
	
    public function getServiciosAdicionales(){
		
        try {

            $query = $this->em->createQuery('SELECT s FROM models\M_servicio_adicional s');

            $servad = $query->getResult();

            return empty($servad) ? FALSE : $servad;
			
        } catch (Exception $e) {
            return $e;
        }
    }
    
    public function getServicios(){
		
        $CI = & get_instance();
        $CI->load->database();
        $query = $CI->db->query('
            select a.nombre, a.importe_menor, a.importe_cadete, 
                a.importe_mayor, a.importe_vitalicio
            from "BD_Operativa".servicio_adicional a
            order by a.nombre');
        $rows = $query->result_array();
        $CI->db->close();
        return $rows;
    }
    
    public function getServiciosEnLimit($comienzo,$cant_reg){
		
        $CI = & get_instance();
        $CI->load->database();
        $query = $CI->db->query('
            select a.nombre, a.importe_menor, a.importe_cadete, 
                a.importe_mayor, a.importe_vitalicio
            from "BD_Operativa".servicio_adicional a
            order by a.nombre
            limit '.$cant_reg.' offset '.$comienzo);
        $rows = $query->result_array();
        $CI->db->close();
        return $rows;
    }
		
}
